Should `keepalive_timeout` be removed from Nginx config?

Posted by Bryson on Server Fault See other posts from Server Fault or by Bryson
Published on 2014-03-21T07:32:51Z Indexed on 2014/08/21 16:22 UTC
Read the original article Hit count: 186

Filed under:
|

Which is the better configuration/optimization: to explicitly limit the keepalive_timeout or to allow Nginx to kill keepalive connections on its own?

I have seen two conflicting recommendations regarding the keepalive_timeout directive for Nginx. They are as follows:

# How long to allow each connection to stay idle; longer values are better
# for each individual client, particularly for SSL, but means that worker
# connections are tied up longer. (Default: 65)
keepalive_timeout  20;

and

# You should remove keepalive_timeout from your formula.
# Nginx closes keepalive connections when the
# worker_connections limit is reached.

The Nginx documentation for keepalive_timeout makes no mention of the automatic killing, and I have only seen this recommendation once, but it intrigues me.

This server serves exclusively TLS-secured connections, and all non-encrypted connections are immediately rerouted to the https:// version of the same URL.

© Server Fault or respective owner

Related posts about nginx

Related posts about keepalive